package Solutions


func missingNumber(nums []int) int {
    length:=len(nums)
    if nums[length-1]!=length{
        return length
    }
    if nums[0]!=0{
        return 0
    }
    sum:=(nums[0]+nums[length-1])*(length+1)/2
    for _,v:=range nums{
        sum-=v
    }
    return sum
}